home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / strobj.zip / TSTROBJ.PAS < prev   
Pascal/Delphi Source File  |  1993-01-04  |  4KB  |  121 lines

  1. {-----------------------------------------------------------------------------}
  2. program TStrObj;                                         { Test MpStrObj Unit }
  3. {-----------------------------------------------------------------------------}
  4.  
  5. {-----------------------------------------------------------------------------}
  6.  
  7. uses
  8.   Crt,
  9.   MpStrObj;
  10.  
  11. {-----------------------------------------------------------------------------}
  12.  
  13. {-----------------------------------------------------------------------------}
  14.  
  15. Var
  16.   aString                    : StringObject;
  17.   pString                    : StringObjectPointer;
  18.  
  19. {-----------------------------------------------------------------------------}
  20.  
  21. {-----------------------------------------------------------------------------}
  22. procedure PauseIt;
  23. begin
  24.  
  25.   GoToXY(1,25);
  26.   Write(' Press ENTER to continue.');
  27.   Readln;
  28.   ClrScr;
  29.  
  30. end;
  31. {-----------------------------------------------------------------------------}
  32.  
  33. {-----------------------------------------------------------------------------}
  34. procedure Printit;
  35. begin
  36.  
  37.   Writeln ( ' aString object is "',aString.Show,'"'^J^M' aString length is ', aString.Len,' bytes.',^J^M );
  38.  
  39. end;
  40. {-----------------------------------------------------------------------------}
  41.  
  42. {-----------------------------------------------------------------------------}
  43. begin
  44.  
  45.   ClrScr;
  46.   Writeln('                                  Testing MpStrObj');
  47.   Writeln;
  48.  
  49.   New (pString);
  50.   pString^.Assign ( ' This is a dynamic string on the heap.');
  51.   Writeln ( ' The value of the dynamic string on the heap is as follows:');
  52.   Writeln ( pString^.Show );
  53.   Writeln;
  54.  
  55.   aString.Assign('This is a string.');
  56.   Writeln ( ' aString.Assign executed... ');
  57.   PrintIt;
  58.  
  59.   aString.PadString ( 23 );
  60.   Writeln( ' aString.PadStr ( 23 ); ');
  61.   PrintIt;
  62.  
  63.   aString.InsertNewChars ( 10, ' nice' );
  64.   Writeln ( ' aString.InsertNewChars ( 10, '' nice'' ); ');
  65.   PrintIt;
  66.  
  67.   pString^.InsertNewChars ( 11, ' nice');
  68.   Writeln ( ' The value of the dynamic string on the heap is as follows:');
  69.   Writeln ( pString^.Show );
  70.   Writeln;
  71.  
  72.   PauseIt;
  73.  
  74.   aString.DeleteChars ( 10, 5 );
  75.   Writeln ( ' aString.DeleteChars ( 10, 5 ); ');
  76.   PrintIt;
  77.  
  78.   aString.MakeUpperCase;
  79.   Writeln ( ' aString.MakeUpperCase; ');
  80.   PrintIt;
  81.  
  82.   aString.Assign ('     String w/leading spaces.');
  83.   Writeln ( ' aString.Assign (''      String w/leading spaces.''); ');
  84.   PrintIt;
  85.  
  86.   aString.StripLeadingSpaces;
  87.   Writeln ( ' aString.StripLeadingSpaces; ');
  88.   PrintIt;
  89.  
  90.   Writeln ( ' aString.CountOccurencesOfChar ( False, ''S'' ); ');
  91.   Writeln(  ' The count is ', aString.CountOccurencesOfChar (False, 'S' ));
  92.   PrintIt;
  93.  
  94.   PauseIt;
  95.   aString.ReplaceAll ('w/leading', 'with leading' );
  96.   Writeln ( ' aString.ReplaceAll (''w/leading'', ''with leading'' ); ');
  97.   PrintIt;
  98.  
  99.   Writeln( ' Testing aString.PositionWhere method: ');
  100.   Writeln( ' The word '' LEADING '' starts at ',aString.PositionWhere ( ' LEADING '), '.' );
  101.  
  102.   Writeln;
  103.   Writeln(' Testing aString.ConstructStringOf ( ''-'', 40 ); ');
  104.   aString.ConstructStringOf ( '-', 40 );
  105.   PrintIt;
  106.  
  107.   Dispose ( pString );
  108.   Writeln(' Got rid of dynamic string.');
  109.   Writeln;
  110.  
  111.   aString.Assign('              ');
  112.   Writeln(' aString initialized to ', aString.Len, ' spaces.');
  113.   Writeln(' Executing aString.StripLeadingSpaces method. ');
  114.   aString.StripLeadingSpaces;
  115.   PrintIt;
  116.  
  117.   Writeln ( ' -*- -*- -*- END OF TEST -*- -*- -*- ');
  118.   PauseIt;
  119.  
  120. end.
  121. {-----------------------------------------------------------------------------}